package com.lyf.alg.practice.newcoder.summary.list;

/**
 （1）统计 - hash计数
 （2）排序 - 类包装-Comparator,Stream,

 **/
import java.util.*;
class Node{
    public char name;
    public int num;// 直接不封装了
    public Node(char name,int num){
        this.name = name;
        this.num = num;
    }
}
public class Main{
    public static void main(String[]args){
        Scanner scanner =new Scanner(System.in);
        String str = scanner.nextLine();

        Map<Character,Integer> hash =new HashMap<>();
        for(int i=0;i<str.length();i++){
            Integer num = hash.get(str.charAt(i));
            if(num==null)
                num=0;
            hash.put(str.charAt(i),num+1);
        }
        List<Node> list=new LinkedList<>();
        for(Map.Entry<Character,Integer> entry:hash.entrySet()){
            list.add(new Node(entry.getKey(),entry.getValue()));
        }

        Collections.sort(list,(node1,node2)->{if(node1.num!=node2.num) return node1.num-node2.num; else return node1.name-node2.name;});
//         list.stream().foreach(i->{
//             System.out.print(i.num);
//         });
        for(Node node:list){
            System.out.print(node.name);
        }
        System.out.println();

    }
}